Skip to content

Conversation

@JimBobSquarePants
Copy link
Member

@JimBobSquarePants JimBobSquarePants commented Nov 27, 2025

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

Fixes #483

This PR fixes a bug where fallback font glyph substitutions were incorrectly using font metrics from the main font instead of the fallback font. This affected complex scripts that require advanced shaping (like Kannada, Indic, Hangul) when rendered with fallback fonts.

  • Threaded FontMetrics parameter through shaper factory and into shapers that perform font-specific lookups
  • Converted static methods to instance methods in shapers to access correct font metrics
  • Optimized by hoisting font metric lookups outside loops where possible

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where fallback font glyph substitutions were incorrectly using font metrics from the main font instead of the fallback font. This affected complex scripts that require advanced shaping (like Kannada, Indic, Hangul) when rendered with fallback fonts.

  • Threaded FontMetrics parameter through shaper factory and into shapers that perform font-specific lookups
  • Converted static methods to instance methods in shapers to access correct font metrics
  • Optimized by hoisting font metric lookups outside loops where possible

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/SixLabors.Fonts.Tests/Issues/Issues_483.cs Adds regression test for Kannada text rendering with fallback fonts using snapshot-based validation
tests/Images/ReferenceOutput/Test_Issue_483-.png Reference snapshot image for the regression test
src/SixLabors.Fonts/Tables/AdvancedTypographic/Shapers/UniversalShaper.cs Adds fontMetrics field and converts methods to instance methods to use correct font metrics
src/SixLabors.Fonts/Tables/AdvancedTypographic/Shapers/ShaperFactory.cs Updates factory to accept and pass fontMetrics parameter to shapers that need it
src/SixLabors.Fonts/Tables/AdvancedTypographic/Shapers/IndicShaper.cs Adds fontMetrics field, optimizes by hoisting lookups outside loops, and uses correct font metrics
src/SixLabors.Fonts/Tables/AdvancedTypographic/Shapers/HangulShaper.cs Adds fontMetrics field, converts methods to instance methods, and simplifies nested conditionals
src/SixLabors.Fonts/Tables/AdvancedTypographic/GSubTable.cs Passes fontMetrics to shaper factory during glyph substitution
src/SixLabors.Fonts/Tables/AdvancedTypographic/GPosTable.cs Passes fontMetrics to shaper factory during glyph positioning
src/SixLabors.Fonts/GlyphSubstitutionCollection.cs Already uses collection expression syntax (no functional change in diff)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@JimBobSquarePants JimBobSquarePants merged commit e831f53 into main Nov 27, 2025
31 checks passed
@JimBobSquarePants JimBobSquarePants deleted the js/fix-483 branch November 27, 2025 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some character / rules are not rendered correctly when the font is used as fallback, but works as main font

2 participants